package org.example.springmvcdemo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/response")
//@RestController
public class ResponseController {
    @RequestMapping("/r1")
    public String r1() {
        return "/index.html";
    }

    @ResponseBody
    @RequestMapping("/r2")
    public Map<String, String> r2() {
        HashMap<String, String> map = new HashMap<>();
        map.put("k1", "v1");
        map.put("k2", "v2");
        return map;
    }

    @ResponseBody
    @RequestMapping(value = "r3", produces = "application/json")
    public String r3() {
        return "123";
    }
}
